import { createRouter, createWebHashHistory } from 'vue-router'
import Login from '../views/Login.vue'
import Other from '../views/Other.vue'
import OpenNew from '../components/OpenNew'
import feedback from '../components/feedback'
import Personinfo from '../components/Personinfo'
import Message from '../components/Message'
import Addmember from '../components/Addmember'
import Bug from '../components/Bug'

const routes = [
  {
    path: '/',
    name: 'Login',
    component: Login,
    meta: {
      title: '登录'
    }
  },
  {
    path: '/main',
    name: 'Main',
    component: ()=>import("../views/Main.vue"),
    meta: {
      title: '首页'
    },
    children: [
      {
        path: 'organizationInfo',
        name: 'organizationInfo',     
        component: ()=>import("../components/organizationInfo"),
        meta: {
          title: '企业/组织信息'
        }
      },
      {
        path: 'Administration',
        name: 'Administration',
        component: ()=>import("../components/Administration"),
        meta: {
          title: '需求管理'
        }
      },
      {
        path: 'Check',
        name: 'Check',
        component: ()=>import("../components/Check"),
        meta: {
          title: '需求查看'
        }
      },
      {
        path: 'feedback',
        name: 'feedback',
        component: feedback,
        meta: {
          title: '需求反馈'
        }
      },
      {
        path: 'watch',
        name: 'watch',
        component: ()=>import("../components/watch"),
        meta: {
          title: '项目速览'
        }
      },
      {
        path: 'OpenNew',
        name: 'OpenNew',
        component: OpenNew,
        meta: {
          title: '开辟项目'
        }
      },      
    ]
  },
  // 下面是用户头像处的跳转
  {
    path: '/other',
    name: 'other',
    component: Other,
    meta: {
      title: '信息页'
    },
    children:[
      {
        path: 'personinfo',
        name: 'personinfo',
        component: Personinfo,
        meta: {
          title: '个人信息'
        }
      },  
      {
        path: 'message',
        name: 'message',
        component: Message,
        meta: {
          title: '我的消息'
        }
      },  
      {
        path: 'addmember',
        name: 'addmember',
        component: Addmember,
        meta: {
          title: '添加成员'
        }
      },  
      {
        path: 'bug',
        name: 'bug',
        component: Bug,
        meta: {
          title: '提交反馈'
        }
      },  
    ]
  }
]

const router = createRouter({
  history: createWebHashHistory(),
  routes
})

router.afterEach((to) => {
  document.title = to.meta.title || '首页'
})

export default router
